Rename dom-control and scheduling interfaces for sanity and consistency.
__asm__ __volatile__ (
TRAP_INSTR
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
- "b" (SCHEDOP_suspend | (STOPCODE_shutdown << SCHEDOP_reasonshift))
+ "b" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
: "memory" );
return ret;
__asm__ __volatile__ (
TRAP_INSTR
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
- "b" (SCHEDOP_suspend | (STOPCODE_reboot << SCHEDOP_reasonshift))
+ "b" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
: "memory" );
return ret;
__asm__ __volatile__ (
TRAP_INSTR
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
- "b" (SCHEDOP_suspend | (STOPCODE_suspend << SCHEDOP_reasonshift)),
+ "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)),
"S" (srec) : "memory" );
return ret;
}
-/******************************************************************************
- * Time-to-die callback handling.
- */
-
-static void shutdown_handler(ctrl_msg_t *msg, unsigned long id)
-{
- extern void ctrl_alt_del(void);
- ctrl_if_send_response(msg);
- ctrl_alt_del();
-}
-
-static int __init setup_shutdown_event(void)
-{
- ctrl_if_register_receiver(CMSG_SHUTDOWN, shutdown_handler, 0);
- return 0;
-}
-
-__initcall(setup_shutdown_event);
-
-
/******************************************************************************
* Stop/pickle callback handling.
*/
static struct tq_struct suspend_tq;
-static void suspend_handler(ctrl_msg_t *msg, unsigned long id)
+static void shutdown_handler(ctrl_msg_t *msg, unsigned long id)
{
- if ( !suspending )
+ if ( msg->subtype != CMSG_SHUTDOWN_SUSPEND )
+ {
+ extern void ctrl_alt_del(void);
+ ctrl_if_send_response(msg);
+ ctrl_alt_del();
+ }
+ else if ( !suspending )
{
suspending = 1;
suspend_tq.routine = suspend_task;
ctrl_if_send_response(msg);
}
-static int __init setup_suspend_event(void)
+static int __init setup_shutdown_event(void)
{
- ctrl_if_register_receiver(CMSG_SUSPEND, suspend_handler, 0);
+ ctrl_if_register_receiver(CMSG_SHUTDOWN, shutdown_handler, 0);
return 0;
}
-__initcall(setup_suspend_event);
+__initcall(setup_shutdown_event);
__asm__ __volatile__ (
TRAP_INSTR
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
- "b" (SCHEDOP_suspend | (STOPCODE_shutdown << SCHEDOP_reasonshift))
+ "b" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
: "memory" );
return ret;
__asm__ __volatile__ (
TRAP_INSTR
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
- "b" (SCHEDOP_suspend | (STOPCODE_reboot << SCHEDOP_reasonshift))
+ "b" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
: "memory" );
return ret;
__asm__ __volatile__ (
TRAP_INSTR
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
- "b" (SCHEDOP_suspend | (STOPCODE_suspend << SCHEDOP_reasonshift)),
+ "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)),
"S" (srec) : "memory" );
return ret;
print >>sys.stderr, """
Usage: %s [command] <params>
- stop [dom] -- pause a domain
- start [dom] -- un-pause a domain
+ pause [dom] -- pause a domain
+ unpause [dom] -- un-pause a domain
shutdown [dom] [[-w]] -- request a domain to shutdown (can specify 'all')
(optionally wait for complete shutdown)
destroy [dom] -- immediately terminate a domain
if len( sys.argv ) > 2 and re.match('\d+$', sys.argv[2]):
dom = int(sys.argv[2])
-if cmd == 'stop':
- rc = xc.domain_stop( dom=dom )
+if cmd == 'pause':
+ rc = xc.domain_pause( dom=dom )
-elif cmd == 'start':
- rc = xc.domain_start( dom=dom )
+elif cmd == 'unpause':
+ rc = xc.domain_unpause( dom=dom )
elif cmd == 'shutdown':
list = []
if dom != None:
- rc = xc.domain_destroy( dom=dom, force=0 )
+ rc = xc.domain_destroy( dom=dom ) # should be CMSG_SHUTDOWN
list.append(dom)
elif sys.argv[2] == 'all':
for i in xc.domain_getinfo():
if i['dom'] != 0: # don't shutdown dom0!
- ret = xc.domain_destroy( dom=i['dom'], force=0 )
+ ret = xc.domain_destroy( dom=i['dom'] ) # should be CMSG_SHUTDOWN
if ret !=0: rc = ret
else: list.append(i['dom'])
time.sleep(1)
elif cmd == 'destroy':
- rc = xc.domain_destroy( dom=dom, force=1 )
+ rc = xc.domain_destroy( dom=dom )
elif cmd == 'pincpu':
run = (domain['running'] and 'r') or '-'
block = (domain['blocked'] and 'b') or '-'
- stop = (domain['stopped'] and 's') or '-'
- susp = (domain['suspended'] and 'S') or '-'
+ stop = (domain['paused'] and 'p') or '-'
+ susp = (domain['shutdown'] and 's') or '-'
crash = (domain['crashed'] and 'c') or '-'
domain['state'] = run + block + stop + susp + crash
if not nlb: print >>open('/proc/sys/net/ipv4/ip_nonlocal_bind','w'), '0'
if not dontstart:
- if xc.domain_start( dom=id ) < 0:
+ if xc.domain_unpause( dom=id ) < 0:
print "Error starting domain"
xc.domain_destroy ( dom=id )
sys.exit()
Usage: %s [command] <params>
help -- print usage
- stop [dom] -- pause a domain
- start [dom] -- un-pause a domain
+ pause [dom] -- pause a domain
+ unpause [dom] -- un-pause a domain
shutdown [dom] [[-w]] -- request a domain to shutdown (can specify 'all')
(optionally wait for complete shutdown)
destroy [dom] -- immediately terminate a domain
if cmd == "help":
usage()
-elif cmd == 'stop':
- rc = server.xend_domain_stop(dom)
+elif cmd == 'pause':
+ rc = server.xend_domain_pause(dom)
-elif cmd == 'start':
- rc = server.xend_domain_start(dom)
+elif cmd == 'unpause':
+ rc = server.xend_domain_unpause(dom)
elif cmd == 'shutdown':
doms = []
else:
console_port = None
- if server.xend_domain_start(dom) < 0:
+ if server.xend_domain_unpause(dom) < 0:
print "Error starting domain"
server.xend_domain_halt(dom)
sys.exit()
typedef struct {
u32 domid;
unsigned int cpu;
- unsigned int dying:1, crashed:1, suspended:1,
- stopped:1, blocked:1, running:1;
+ unsigned int dying:1, crashed:1, shutdown:1,
+ paused:1, blocked:1, running:1;
unsigned long nr_pages;
unsigned long shared_info_frame;
u64 cpu_time;
const char *name,
int cpu,
u32 *pdomid);
-int xc_domain_start(int xc_handle,
+int xc_domain_pause(int xc_handle,
u32 domid);
-int xc_domain_stop(int xc_handle,
- u32 domid);
+int xc_domain_unpause(int xc_handle,
+ u32 domid);
int xc_domain_destroy(int xc_handle,
- u32 domid,
- int force);
+ u32 domid);
int xc_domain_pincpu(int xc_handle,
u32 domid,
int cpu);
}
-int xc_domain_start(int xc_handle,
+int xc_domain_pause(int xc_handle,
u32 domid)
{
dom0_op_t op;
- op.cmd = DOM0_STARTDOMAIN;
- op.u.startdomain.domain = (domid_t)domid;
+ op.cmd = DOM0_PAUSEDOMAIN;
+ op.u.pausedomain.domain = (domid_t)domid;
return do_dom0_op(xc_handle, &op);
}
-int xc_domain_stop(int xc_handle,
- u32 domid)
+int xc_domain_unpause(int xc_handle,
+ u32 domid)
{
dom0_op_t op;
- op.cmd = DOM0_STOPDOMAIN;
- op.u.stopdomain.domain = (domid_t)domid;
+ op.cmd = DOM0_UNPAUSEDOMAIN;
+ op.u.unpausedomain.domain = (domid_t)domid;
return do_dom0_op(xc_handle, &op);
}
int xc_domain_destroy(int xc_handle,
- u32 domid,
- int force)
+ u32 domid)
{
dom0_op_t op;
op.cmd = DOM0_DESTROYDOMAIN;
op.u.destroydomain.domain = (domid_t)domid;
- op.u.destroydomain.force = !!force;
return do_dom0_op(xc_handle, &op);
}
info->cpu =
(op.u.getdomaininfo.flags>>DOMFLAGS_CPUSHIFT) & DOMFLAGS_CPUMASK;
- info->dying = (op.u.getdomaininfo.flags & DOMFLAGS_DYING);
- info->crashed = (op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
- info->suspended = (op.u.getdomaininfo.flags & DOMFLAGS_SUSPENDED);
- info->stopped = (op.u.getdomaininfo.flags & DOMFLAGS_STOPPED);
- info->blocked = (op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
- info->running = (op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
+ info->dying = (op.u.getdomaininfo.flags & DOMFLAGS_DYING);
+ info->crashed = (op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
+ info->shutdown = (op.u.getdomaininfo.flags & DOMFLAGS_SHUTDOWN);
+ info->paused = (op.u.getdomaininfo.flags & DOMFLAGS_PAUSED);
+ info->blocked = (op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
+ info->running = (op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
info->nr_pages = op.u.getdomaininfo.tot_pages;
info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT-10);
PERROR("Could not get info on domain");
goto error_out;
}
- if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
+ if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
(ctxt->pt_base != 0) )
{
ERROR("Domain is already constructed");
out:
- if ( rc != 0 )
- {
- if ( dom != 0 )
- {
- xc_domain_destroy( xc_handle, dom, 1 );
- }
- }
+ if ( (rc != 0) && (dom != 0) )
+ xc_domain_destroy(xc_handle, dom);
if ( mmu != NULL )
free(mmu);
}
/* Ensure that the domain exists, and that it is stopped. */
-
- if ( xc_domain_stop_sync( xc_handle, domid, &op, &ctxt ) )
+ if ( xc_domain_pause(xc_handle, domid) )
{
- PERROR("Could not sync stop domain");
+ PERROR("Could not pause domain");
goto out;
}
goto out;
}
- if ( xc_domain_start( xc_handle, domid ) < 0 )
+ if ( xc_domain_unpause(xc_handle, domid) < 0 )
{
- ERROR("Couldn't restart domain");
+ ERROR("Couldn't unpause domain");
goto out;
}
DPRINTF("Start last iteration\n");
last_iter = 1;
- xc_domain_stop_sync( xc_handle, domid, &op, NULL );
-
+ xc_domain_pause(xc_handle, domid);
}
if ( xc_shadow_control( xc_handle, domid,
PERROR("Could not get info on domain");
goto error_out;
}
- if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
+ if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
(op.u.getdomaininfo.ctxt->pt_base != 0) )
{
ERROR("Domain is already constructed");
}
-/***********************************************************/
-
-/* this function is a hack until we get proper synchronous domain stop */
-
-int xc_domain_stop_sync( int xc_handle, domid_t domid,
- dom0_op_t *op, full_execution_context_t *ctxt)
-{
- op->cmd = DOM0_STOPDOMAIN;
- op->u.stopdomain.domain = (domid_t)domid;
- do_dom0_op(xc_handle, op);
- return 0;
-}
-
long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid )
{
dom0_op_t op;
}
-/**********************************************************************/
-
/* This is shared between save and restore, and may generally be useful. */
unsigned long csum_page (void * page)
{
void * mfn_mapper_queue_entry(mfn_mapper_t *t, int offset,
unsigned long mfn, int size );
-/*********************/
-
-int xc_domain_stop_sync( int xc_handle, domid_t dom,
- dom0_op_t *op, full_execution_context_t *ctxt );
-
long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid );
#endif /* __XC_PRIVATE_H__ */
return PyInt_FromLong(dom);
}
-static PyObject *pyxc_domain_start(PyObject *self,
+static PyObject *pyxc_domain_pause(PyObject *self,
PyObject *args,
PyObject *kwds)
{
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
return NULL;
- if ( xc_domain_start(xc->xc_handle, dom) != 0 )
+ if ( xc_domain_pause(xc->xc_handle, dom) != 0 )
return PyErr_SetFromErrno(xc_error);
Py_INCREF(zero);
return zero;
}
-static PyObject *pyxc_domain_stop(PyObject *self,
- PyObject *args,
- PyObject *kwds)
+static PyObject *pyxc_domain_unpause(PyObject *self,
+ PyObject *args,
+ PyObject *kwds)
{
XcObject *xc = (XcObject *)self;
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
return NULL;
- if ( xc_domain_stop(xc->xc_handle, dom) != 0 )
+ if ( xc_domain_unpause(xc->xc_handle, dom) != 0 )
return PyErr_SetFromErrno(xc_error);
Py_INCREF(zero);
XcObject *xc = (XcObject *)self;
u32 dom;
- int force = 0;
- static char *kwd_list[] = { "dom", "force", NULL };
+ static char *kwd_list[] = { "dom", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
- &dom, &force) )
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
return NULL;
- if ( xc_domain_destroy(xc->xc_handle, dom, force) != 0 )
+ if ( xc_domain_destroy(xc->xc_handle, dom) != 0 )
return PyErr_SetFromErrno(xc_error);
Py_INCREF(zero);
"cpu", info[i].cpu,
"dying", info[i].dying,
"crashed", info[i].crashed,
- "suspended", info[i].suspended,
- "stopped", info[i].stopped,
+ "shutdown", info[i].shutdown,
+ "paused", info[i].paused,
"blocked", info[i].blocked,
"running", info[i].running,
"mem_kb", info[i].nr_pages*4,
if ( rc == 0 )
{
printf("Migration succesful -- destroy local copy\n");
- xc_domain_destroy( xc->xc_handle, dom, 1 );
+ xc_domain_destroy(xc->xc_handle, dom);
close(sd);
Py_INCREF(zero);
return zero;
serr:
printf("Migration failed -- restart local copy\n");
- xc_domain_start( xc->xc_handle, dom );
+ xc_domain_unpause(xc->xc_handle, dom);
PyErr_SetFromErrno(xc_error);
if ( sd >= 0 ) close(sd);
return NULL;
/* kill domain. We don't want to do this for checkpointing, but
if we don't do it here I think people will hurt themselves
by accident... */
- xc_domain_destroy( xc->xc_handle, dom, 1 );
+ xc_domain_destroy(xc->xc_handle, dom);
gzclose(gfd);
close(fd);
" name [str, '(anon)']: Informative textual name.\n\n"
"Returns: [int] new domain identifier; -1 on error.\n" },
- { "domain_start",
- (PyCFunction)pyxc_domain_start,
+ { "domain_pause",
+ (PyCFunction)pyxc_domain_pause,
METH_VARARGS | METH_KEYWORDS, "\n"
- "Start execution of a domain.\n"
- " dom [int]: Identifier of domain to be started.\n\n"
+ "Temporarily pause execution of a domain.\n"
+ " dom [int]: Identifier of domain to be paused.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_stop",
- (PyCFunction)pyxc_domain_stop,
+ { "domain_unpause",
+ (PyCFunction)pyxc_domain_unpause,
METH_VARARGS | METH_KEYWORDS, "\n"
- "Stop execution of a domain.\n"
- " dom [int]: Identifier of domain to be stopped.\n\n"
+ "(Re)start execution of a domain.\n"
+ " dom [int]: Identifier of domain to be unpaused.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_destroy",
(PyCFunction)pyxc_domain_destroy,
METH_VARARGS | METH_KEYWORDS, "\n"
"Destroy a domain.\n"
- " dom [int]: Identifier of domain to be destroyed.\n"
- " force [int, 0]: Bool - force immediate destruction?\n\n"
+ " dom [int]: Identifier of domain to be destroyed.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_pincpu",
" cpu [int]: CPU to which this domain is bound\n"
" dying [int]: Bool - is the domain dying?\n"
" crashed [int]: Bool - has the domain crashed?\n"
- " suspended[int]: Bool - has the domain suspended itself?\n"
- " stopped [int]: Bool - is the domain stopped by control software?\n"
+ " shutdown [int]: Bool - has the domain shut itself down?\n"
+ " paused [int]: Bool - is the domain paused by control software?\n"
" blocked [int]: Bool - is the domain blocked waiting for an event?\n"
" running [int]: Bool - is the domain currently running?\n"
" mem_kb [int]: Memory reservation, in kilobytes\n"
/*
- * Stop codes for SCHEDOP_suspend. These are opaque to Xen but interpreted by
- * control software to determine appropriate action.
+ * Reason codes for SCHEDOP_shutdown. These are opaque to Xen but may be
+ * interpreted by control software to determine the appropriate action. These
+ * are only really advisories: the controller can actually do as it likes.
*/
-
-#define STOPCODE_shutdown 0 /* Domain exited normally. Clean up and kill. */
-#define STOPCODE_reboot 1 /* Clean up, kill, and then restart. */
-#define STOPCODE_suspend 2 /* Clean up, save suspend info, kill. */
+#define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
+#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
+#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
/*
#define CMSG_BLKIF_FE 2 /* Block-device frontend */
#define CMSG_NETIF_BE 3 /* Network-device backend */
#define CMSG_NETIF_FE 4 /* Network-device frontend */
-#define CMSG_SUSPEND 5 /* Suspend messages */
#define CMSG_SHUTDOWN 6 /* Shutdown messages */
} PACKED netif_be_driver_status_changed_t; /* 4 bytes */
-/******************************************************************************
- * SUSPEND DEFINITIONS
- */
-
-/*
- * Subtypes for console messages.
- */
-/* None. */
-
-
/******************************************************************************
* CONSOLE DEFINITIONS
*/
/*
* Subtypes for console messages.
*/
-#define CMSG_SHUTDOWN_HALT 0 /* Shutdown and halt (don't die). */
-#define CMSG_SHUTDOWN_POWEROFF 1 /* 'Poweroff' => clean death. */
-#define CMSG_SHUTDOWN_REBOOT 2 /* Shutdown and restart. */
-
+#define CMSG_SHUTDOWN_POWEROFF 0 /* Clean shutdown (SHUTDOWN_poweroff). */
+#define CMSG_SHUTDOWN_REBOOT 1 /* Clean shutdown (SHUTDOWN_reboot). */
+#define CMSG_SHUTDOWN_SUSPEND 2 /* Create suspend info, then */
+ /* SHUTDOWN_suspend. */
#endif /* __DOMAIN_CONTROLLER_H__ */
## xend.domain.destroy: dom, reason:died/crashed
## xend.domain.up ?
-## xend.domain.start: dom
-## xend.domain.stop: dom
+## xend.domain.unpause: dom
+## xend.domain.pause: dom
## xend.domain.shutdown: dom
## xend.domain.halt: dom
def xend_domain(self, id):
return xend_get(self.domainurl(id))
- def xend_domain_start(self, id):
+ def xend_domain_unpause(self, id):
return xend_call(self.domainurl(id),
- {'op' : 'start'})
+ {'op' : 'unpause'})
- def xend_domain_stop(self, id):
+ def xend_domain_pause(self, id):
return xend_call(self.domainurl(id),
- {'op' : 'stop'})
+ {'op' : 'pause'})
def xend_domain_shutdown(self, id):
return xend_call(self.domainurl(id),
self.refresh_domain(id)
return self.domain[id]
- def domain_start(self, id):
- """Start domain running.
+ def domain_unpause(self, id):
+ """(Re)start domain running.
"""
dom = int(id)
- eserver.inject('xend.domain.start', id)
- return xc.domain_start(dom=dom)
+ eserver.inject('xend.domain.unpause', id)
+ return xc.domain_unpause(dom=dom)
- def domain_stop(self, id):
- """Stop domain running.
+ def domain_pause(self, id):
+ """Pause domain execution.
"""
dom = int(id)
- return xc.domain_stop(dom=dom)
+ return xc.domain_pause(dom=dom)
def domain_shutdown(self, id):
"""Shutdown domain (nicely).
if dom <= 0:
return 0
eserver.inject('xend.domain.shutdown', id)
- val = xc.domain_destroy(dom=dom, force=0)
+ val = xc.domain_destroy(dom=dom) # FIXME -- send CMSG_SHUTDOWN
self.refresh()
return val
if dom <= 0:
return 0
eserver.inject('xend.domain.halt', id)
- val = xc.domain_destroy(dom=dom, force=1)
+ val = xc.domain_destroy(dom=dom)
self.refresh()
return val
"""Save domain state to file, halt domain.
"""
dom = int(id)
- self.domain_stop(id)
+ self.domain_pause(id)
eserver.inject('xend.domain.save', id)
rc = xc.linux_save(dom=dom, state_file=dst, progress=progress)
if rc == 0:
if self.info:
run = (self.info['running'] and 'r') or '-'
block = (self.info['blocked'] and 'b') or '-'
- stop = (self.info['stopped'] and 's') or '-'
- susp = (self.info['suspended'] and 'S') or '-'
+ stop = (self.info['paused'] and 'p') or '-'
+ susp = (self.info['shutdown'] and 's') or '-'
crash = (self.info['crashed'] and 'c') or '-'
state = run + block + stop + susp + crash
sxpr.append(['cpu', self.info['cpu']])
def destroy(self):
if self.dom <= 0:
return 0
- return xc.domain_destroy(dom=self.dom, force=1)
+ return xc.domain_destroy(dom=self.dom)
def show(self):
"""Print virtual machine info.
self.xd = XendDomain.instance()
self.xconsole = XendConsole.instance()
- def op_start(self, op, req):
- val = self.xd.domain_start(self.dom.id)
+ def op_unpause(self, op, req):
+ val = self.xd.domain_unpause(self.dom.id)
return val
- def op_stop(self, op, req):
- val = self.xd.domain_stop(self.dom.id)
+ def op_pause(self, op, req):
+ val = self.xd.domain_pause(self.dom.id)
return val
def op_shutdown(self, op, req):
else:
console_port = None
- if server.xend_domain_start(dom) < 0:
+ if server.xend_domain_unpause(dom) < 0:
server.xend_domain_halt(dom)
opts.err("Failed to start domain %d" % dom)
opts.info("Started domain %d, console on port %d"
"""Shutdown a domain."""
shutdown.main(args)
- def xm_stop(self, help, args):
- """Stop execution of a domain."""
+ def xm_pause(self, help, args):
+ """Pause execution of a domain."""
if help:
print args[0], 'DOM'
- print '\nStop execution of domain DOM.'
+ print '\nPause execution of domain DOM.'
return
if len(args) < 2: self.err("%s: Missing domain" % args[0])
dom = args[1]
- server.xend_domain_stop(dom)
+ server.xend_domain_pause(dom)
- def xm_start(self, help, args):
- """Start execution of a domain."""
+ def xm_unpause(self, help, args):
+ """(Re)start execution of a domain."""
if help:
print args[0], 'DOM'
- print '\nStart execution of domain DOM.'
+ print '\n(Re)start execution of domain DOM.'
return
if len(args) < 2: self.err("%s: Missing domain" % args[0])
dom = args[1]
- server.xend_domain_start(dom)
+ server.xend_domain_unpause(dom)
def xm_pincpu(self, help, args):
"""Pin a domain to a cpu. """
{
/* Just some sanity to ensure that the scheduler is set up okay. */
ASSERT(current->domain == IDLE_DOMAIN_ID);
- domain_start(current);
+ domain_unpause_by_systemcontroller(current);
__enter_scheduler();
/*
struct domain *d = find_domain_by_id(op->u.debug.domain);
if ( d != NULL )
{
- domain_start(d);
+ domain_unpause_by_systemcontroller(d);
put_domain(d);
}
else
if ( d != NULL )
{
- domain_stop(d);
+ domain_pause_by_systemcontroller(d);
put_domain(d);
}
else
}
break;
- case DOM0_STARTDOMAIN:
+ case DOM0_PAUSEDOMAIN:
{
- struct domain *d = find_domain_by_id(op->u.startdomain.domain);
+ struct domain *d = find_domain_by_id(op->u.pausedomain.domain);
ret = -ESRCH;
if ( d != NULL )
{
ret = -EINVAL;
- if ( test_bit(DF_CONSTRUCTED, &d->flags) )
+ if ( d != current )
{
- domain_start(d);
+ domain_pause_by_systemcontroller(d);
ret = 0;
}
put_domain(d);
}
break;
- case DOM0_STOPDOMAIN:
+ case DOM0_UNPAUSEDOMAIN:
{
- struct domain *d = find_domain_by_id(op->u.stopdomain.domain);
+ struct domain *d = find_domain_by_id(op->u.unpausedomain.domain);
ret = -ESRCH;
if ( d != NULL )
{
ret = -EINVAL;
- if ( d != current )
+ if ( test_bit(DF_CONSTRUCTED, &d->flags) )
{
- domain_stop(d);
+ domain_unpause_by_systemcontroller(d);
ret = 0;
}
put_domain(d);
strcpy(op->u.getdomaininfo.name, d->name);
op->u.getdomaininfo.flags =
- (test_bit(DF_DYING, &d->flags) ? DOMFLAGS_DYING : 0) |
- (test_bit(DF_CRASHED, &d->flags) ? DOMFLAGS_CRASHED : 0) |
- (test_bit(DF_SUSPENDED, &d->flags) ? DOMFLAGS_SUSPENDED : 0) |
- (test_bit(DF_STOPPED, &d->flags) ? DOMFLAGS_STOPPED : 0) |
- (test_bit(DF_BLOCKED, &d->flags) ? DOMFLAGS_BLOCKED : 0) |
- (test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0);
+ (test_bit(DF_DYING, &d->flags) ? DOMFLAGS_DYING : 0) |
+ (test_bit(DF_CRASHED, &d->flags) ? DOMFLAGS_CRASHED : 0) |
+ (test_bit(DF_SHUTDOWN, &d->flags) ? DOMFLAGS_SHUTDOWN : 0) |
+ (test_bit(DF_CTRLPAUSE, &d->flags) ? DOMFLAGS_PAUSED : 0) |
+ (test_bit(DF_BLOCKED, &d->flags) ? DOMFLAGS_BLOCKED : 0) |
+ (test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0);
op->u.getdomaininfo.flags |= d->processor << DOMFLAGS_CPUSHIFT;
op->u.getdomaininfo.flags |=
- d->suspend_code << DOMFLAGS_SUSPCODESHIFT;
+ d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
op->u.getdomaininfo.tot_pages = d->tot_pages;
op->u.getdomaininfo.max_pages = d->max_pages;
#include <xen/shadow.h>
#include <xen/console.h>
#include <xen/shadow.h>
+#include <xen/irq.h>
#include <asm/io.h>
#include <asm/domain_page.h>
#include <asm/flushtlb.h>
BUG();
}
-void domain_suspend(u8 reason)
+void domain_shutdown(u8 reason)
{
struct domain *d;
if ( current->domain == 0 )
{
extern void machine_restart(char *);
- printk("Domain 0 halted: rebooting machine!\n");
+ printk("Domain 0 shutdown: rebooting machine!\n");
machine_restart(0);
}
- current->suspend_code = reason;
- set_bit(DF_SUSPENDED, ¤t->flags);
+ current->shutdown_code = reason;
+ set_bit(DF_SHUTDOWN, ¤t->flags);
d = find_domain_by_id(0);
send_guest_virq(d, VIRQ_DOM_EXC);
init_trace_bufs();
- domain_start(current);
- domain_start(new_dom);
+ domain_unpause_by_systemcontroller(current);
+ domain_unpause_by_systemcontroller(new_dom);
startup_cpu_idle_loop();
}
*/
void sched_add_domain(struct domain *d)
{
- set_bit(DF_STOPPED, &d->flags);
+ /* Must be unpaused by control software to start execution. */
+ set_bit(DF_CTRLPAUSE, &d->flags);
if ( d->domain != IDLE_DOMAIN_ID )
{
break;
}
- case SCHEDOP_suspend:
+ case SCHEDOP_shutdown:
{
- domain_suspend((u8)(op >> SCHEDOP_reasonshift));
+ domain_shutdown((u8)(op >> SCHEDOP_reasonshift));
break;
}
/* Might as well stop the domain as an optimization. */
if ( zero )
- domain_stop(d);
+ domain_pause_by_systemcontroller(d);
break;
}
* This makes sure that old versions of dom0 tools will stop working in a
* well-defined way (rather than crashing the machine, for instance).
*/
-#define DOM0_INTERFACE_VERSION 0xAAAA000F
+#define DOM0_INTERFACE_VERSION 0xAAAA0010
#define MAX_DOMAIN_NAME 16
typedef struct {
/* IN variables. */
domid_t domain; /* 0 */
- u32 force; /* 4 */
-} PACKED dom0_destroydomain_t; /* 8 bytes */
+} PACKED dom0_destroydomain_t; /* 4 bytes */
-#define DOM0_STARTDOMAIN 10
+#define DOM0_PAUSEDOMAIN 10
typedef struct {
/* IN parameters. */
domid_t domain; /* 0 */
-} PACKED dom0_startdomain_t; /* 4 bytes */
+} PACKED dom0_pausedomain_t; /* 4 bytes */
-#define DOM0_STOPDOMAIN 11
+#define DOM0_UNPAUSEDOMAIN 11
typedef struct {
/* IN parameters. */
domid_t domain; /* 0 */
-} PACKED dom0_stopdomain_t; /* 4 bytes */
+} PACKED dom0_unpausedomain_t; /* 4 bytes */
#define DOM0_GETDOMAININFO 12
typedef struct {
/* OUT variables. */
#define DOMFLAGS_DYING (1<<0) /* Domain is scheduled to die. */
#define DOMFLAGS_CRASHED (1<<1) /* Crashed domain; frozen for postmortem. */
-#define DOMFLAGS_SUSPENDED (1<<2) /* Domain voluntarily halted it execution. */
-#define DOMFLAGS_STOPPED (1<<3) /* Currently stopped by control software. */
+#define DOMFLAGS_SHUTDOWN (1<<2) /* The guest OS has shut itself down. */
+#define DOMFLAGS_PAUSED (1<<3) /* Currently paused by control software. */
#define DOMFLAGS_BLOCKED (1<<4) /* Currently blocked pending an event. */
#define DOMFLAGS_RUNNING (1<<5) /* Domain is currently running. */
#define DOMFLAGS_CPUMASK 255 /* CPU to which this domain is bound. */
#define DOMFLAGS_CPUSHIFT 8
-#define DOMFLAGS_SUSPCODEMASK 255 /* DOMSTATE_SUSPENDED guest-supplied code. */
-#define DOMFLAGS_SUSPCODESHIFT 16
+#define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code. */
+#define DOMFLAGS_SHUTDOWNSHIFT 16
u32 flags; /* 4 */
u8 name[MAX_DOMAIN_NAME]; /* 8 */
full_execution_context_t *ctxt; /* 24 */ /* NB. IN/OUT variable. */
union { /* 8 */
u32 dummy[18]; /* 72 bytes */
dom0_createdomain_t createdomain;
- dom0_startdomain_t startdomain;
- dom0_stopdomain_t stopdomain;
+ dom0_pausedomain_t pausedomain;
+ dom0_unpausedomain_t unpausedomain;
dom0_destroydomain_t destroydomain;
dom0_getmemlist_t getmemlist;
dom0_schedctl_t schedctl;
*/
#define SCHEDOP_yield 0 /* Give up the CPU voluntarily. */
#define SCHEDOP_block 1 /* Block until an event is received. */
-#define SCHEDOP_suspend 2 /* Stop executing this domain. */
+#define SCHEDOP_shutdown 2 /* Stop executing this domain. */
#define SCHEDOP_cmdmask 255 /* 8-bit command. */
-#define SCHEDOP_reasonshift 8 /* 8-bit suspend code. (SCHEDOP_suspend) */
+#define SCHEDOP_reasonshift 8 /* 8-bit reason code. (SCHEDOP_shutdown) */
/*
* Commands to HYPERVISOR_console_io().
/* Scheduling. */
struct list_head run_list;
- int suspend_code; /* code value from OS (if DF_SUSPENDED). */
+ int shutdown_code; /* code value from OS (if DF_SHUTDOWN). */
s_time_t lastschd; /* time this domain was last scheduled */
s_time_t lastdeschd; /* time this domain was last descheduled */
s_time_t cpu_time; /* total CPU time received till now */
extern void domain_destruct(struct domain *d);
extern void domain_kill(struct domain *d);
extern void domain_crash(void);
-extern void domain_suspend(u8 reason);
+extern void domain_shutdown(u8 reason);
/* arch/process.c */
void new_thread(struct domain *d,
#define DF_CONSOLEWRITEBUG 6 /* Has this domain used the obsolete console? */
#define DF_PHYSDEV 7 /* May this domain do IO to physical devices? */
#define DF_BLOCKED 8 /* Domain is blocked waiting for an event. */
-#define DF_STOPPED 9 /* Domain is stopped by control software. */
-#define DF_SUSPENDED 10 /* Guest suspended its execution for some reason. */
+#define DF_CTRLPAUSE 9 /* Domain is paused by controller software. */
+#define DF_SHUTDOWN 10 /* Guest shut itself down for some reason. */
#define DF_CRASHED 11 /* Domain crashed inside Xen, cannot continue. */
#define DF_DYING 12 /* Death rattle. */
#define DF_RUNNING 13 /* Currently running on a CPU. */
static inline int domain_runnable(struct domain *d)
{
return ( (atomic_read(&d->pausecnt) == 0) &&
- !(d->flags & ((1<<DF_BLOCKED)|(1<<DF_STOPPED)|
- (1<<DF_SUSPENDED)|(1<<DF_CRASHED))) );
+ !(d->flags & ((1<<DF_BLOCKED)|(1<<DF_CTRLPAUSE)|
+ (1<<DF_SHUTDOWN)|(1<<DF_CRASHED))) );
}
static inline void domain_pause(struct domain *d)
domain_wake(d);
}
-static inline void domain_unsuspend(struct domain *d)
+static inline void domain_pause_by_systemcontroller(struct domain *d)
{
ASSERT(d != current);
- if ( test_and_clear_bit(DF_SUSPENDED, &d->flags) )
- domain_wake(d);
-}
-
-static inline void domain_stop(struct domain *d)
-{
- ASSERT(d != current);
- if ( !test_and_set_bit(DF_STOPPED, &d->flags) )
+ if ( !test_and_set_bit(DF_CTRLPAUSE, &d->flags) )
domain_sleep(d);
}
-static inline void domain_start(struct domain *d)
+static inline void domain_unpause_by_systemcontroller(struct domain *d)
{
ASSERT(d != current);
- if ( test_and_clear_bit(DF_STOPPED, &d->flags) )
+ if ( test_and_clear_bit(DF_CTRLPAUSE, &d->flags) )
domain_wake(d);
}